import 'package:flutter/material.dart';

class ShoppingCarPage extends StatelessWidget {

  final List<String> items;
  ShoppingCarPage({Key key,@required this.items}):super(key:key);
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Bar',
      theme: ThemeData(
        primaryColor: Colors.white,
      ),
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('购物车'),
        ),
        // body: new Center(
        //   child: new Container(
        //     child: Image.network(
        //       'https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1545119878&di=180ebe589d0149816f913f666a6fa140&src=http://hbimg.b0.upaiyun.com/69c1e587729088bf34d7bd5fa6b56d78c572334d42b1-Jk8qA5_fw658',
        //         scale:1.0,
        //     ),
        //     width: 200,
        //     height: 100,
        //   )
        // ),
        // 列表
        // body: new ListView(
        //   children: <Widget>[
        //     new ListTile(
        //       leading: Icon(Icons.ac_unit),
        //       title:new Text('这是一个小图标'),
        //     ),
        //      new ListTile(
        //       leading: Icon(Icons.access_alarm),
        //       title:new Text('这是另一个小图标'),
        //     )
        //   ],
        // )
        //抽离组件
        // body:Center(
        //   child: Container(
        //     height: 200,
        //     child:MyList(),
        //     padding: EdgeInsets.all(10),
        //     decoration: new BoxDecoration(
        //       border:Border.all(width:10,color:Colors.red)
        //     ),
        //   ),
        // )
        body:new ListView.builder(
          itemCount: items.length,
          itemBuilder: (context,index){
            return new ListTile(
              title: new Text('商品列表${items[index]}'),
            );
          },
        )
      ),
    );
  }
}

 class MyList extends StatelessWidget{
   @override
   Widget build(BuildContext context){
     return ListView (
              // 横向滚动
              scrollDirection: Axis.horizontal,
              children: <Widget>[
                new Container(
                  width: 180,
                  color: Colors.lightBlue,
                ),
                 new Container(
                  width: 180,
                  color: Colors.lightGreen,
                ),
                new Container(
                  width: 180,
                  color: Colors.limeAccent,
                ),
                new Container(
                  width: 180,
                  color: Colors.orange,
                ),
              ],
     );
   }
 }